<?php if (!defined('THINK_PATH')) exit(); /*a:5:{s:73:"E:\workplace\project\Sunwm\web/../application/admin\view\order\index.html";i:1512719939;s:75:"E:\workplace\project\Sunwm\web/../application/admin\view\public\header.html";i:1503189484;s:73:"E:\workplace\project\Sunwm\web/../application/admin\view\public\city.html";i:1510310973;s:74:"E:\workplace\project\Sunwm\web/../application/admin\view\public\pages.html";i:1509260822;s:75:"E:\workplace\project\Sunwm\web/../application/admin\view\public\footer.html";i:1512624954;}*/ ?>
﻿<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title><?php echo config('sitename'); ?>-<?php echo lang('label')['Login_title']; ?></title>
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/public/css/pintuer.css" />
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/admin/css/admin.css" />
		<script type="text/javascript" src="__ROOT__/static/public/js/jquery.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/js/pintuer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/admin/js/admin.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/layer/layer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laydate/laydate.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laytpl/laytpl.js"></script>
	</head>

	<body>
	<style>
		html { overflow-x:hidden; }
	</style>
			<form method="post">
				<div class="panel admin-panel">
					<div class="panel-head"><strong><?php echo lang('currency')['list']; ?></strong></div>
					<div class="padding border-bottom">
						<script>
						//city 参数和回调
						var pid="<?php echo input('get.pid'); ?>";
						var cid="<?php echo input('get.cid'); ?>";
						var aid="<?php echo input('get.aid'); ?>";
						var selectc=true;
						var selecta=true;
						function select_p(){
							return false;
						}
						function select_c(){
							return false;
						}
						function select_a(){
							var express_id = $("#express").val();
							var seller_id = $("#seller").val();
							var status = $("#status").val();
							location.href="<?php echo url('/admin/order'); ?>?pid="+pid+"&cid="+cid+"&aid="+aid+"&status="+status+"&seller_id="+seller_id+"&express_id="+express_id+"&start_time="+start_time+"&end_time="+end_time;
							//location.href="<?php echo url('/admin/order'); ?>?pid="+pid+"&cid="+cid+"&aid="+aid;
						}
						</script>
						<?php echo lang('label')['select']; ?><?php echo lang('currency')['city']; ?>:<?php if(input('session.type') == 'province' || input('session.type') == 'all'): ?>
<select id="province" onchange="pchange(this.value)" name="pid" class="input input-auto" >
	<option value="">请选择</option>
</select>
<?php endif; if(input('session.type') == 'province' ||  input('session.type') == 'city' || input('session.type') == 'all'): ?>
<select id="city" onchange="cchange(this.value)" name="cid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<?php endif; ?>
<select id="area" onchange="achange(this.value)" name="aid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<script id="province_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==pid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="city_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==cid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="area_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==aid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script>
    var func = false;
    $('select').click(function(){
        func = true;
    });
    if(selectc) {
        $('[name=cid]').removeClass('hidden');
    }
    if(selecta){
        $('[name=aid]').removeClass('hidden');
    }
    if('<?php echo input("session.type"); ?>' == 'province' || '<?php echo input("session.type"); ?>' == 'all') {
        $.getJSON('__ROOT__/admin/city/ajax_get?type=province', {}, function (res) {
            var tpl = $("#province_list_tpl").html();
            laytpl(tpl).render(res, function (render) {
                $("#province").html('<option value="">请选择</option>' + render);
            });
            if (pid != '' && pid != 0) {
                $('[name=pid]').change();
            }
        });
    }else if('<?php echo input("session.type"); ?>' == 'city'){
        val = '<?php echo input("session.aid"); ?>';
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+val, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>' + render);
                    $("#city").val(cid);
                    $("#city").change();
                });
            });
        }
    }else if('<?php echo input("session.type"); ?>' == 'area'){
        val = '<?php echo input("session.aid"); ?>';
        //if(selecta && aid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&nofather=ok&id='+val, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
       // }
    }
    function pchange(val) {
        pid = val;
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+pid, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>'+render);
                });
                if(selectc == true){
                    if(cid != '' && cid != 0){
                        $('[name=cid]').change();
                    }
                }
            });
        }
        if(func){
            select_p();
        }
    }
    function cchange(val) {
        cid = val;
        if(selecta && cid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&id='+cid, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
        }
        if(func){
            select_c();
        }
    }
    function achange(val) {
        aid = val;
        $('[name=aid]').removeClass('hidden');
        if(func){
            select_a();
        }
    }
</script>
						订单状态：
						<select class="input input-auto" id="status">
							<option value="">请选择</option>
							<?php $__FOR_START_31040__=1;$__FOR_END_31040__=8;for($i=$__FOR_START_31040__;$i < $__FOR_END_31040__;$i+=1){ ?> 
							<option <?php if($_GET['status'] == $i): ?>selected<?php endif; ?> value="<?php echo $i; ?>"><?php echo lang('label')['order_status_'.$i]; ?></option>
							<?php } ?>
							<option <?php if($_GET['status'] == 8): ?>selected<?php endif; ?> value="8">待商家接单</option>
						</select>
						商家：
						<select class="input input-auto" id="seller">
							<option value="">请选择</option>
							<?php if(is_array($sellerlist) || $sellerlist instanceof \think\Collection || $sellerlist instanceof \think\Paginator): $i = 0; $__LIST__ = $sellerlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$seller): $mod = ($i % 2 );++$i;?>
							<option <?php if($_GET['seller_id'] == $seller['id']): ?>selected<?php endif; ?> value="<?php echo $seller['id']; ?>"><?php echo $seller['name']; ?></option>
							<?php endforeach; endif; else: echo "" ;endif; ?>
						</select>
						配送员：
						<select class="input input-auto" id="express">
							<option value="">请选择</option>
							<?php if(is_array($expresslist) || $expresslist instanceof \think\Collection || $expresslist instanceof \think\Paginator): $i = 0; $__LIST__ = $expresslist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$express): $mod = ($i % 2 );++$i;?>
							<option <?php if($_GET['express_id'] == $express['id']): ?>selected<?php endif; ?> value="<?php echo $express['id']; ?>"><?php echo $express['name']; ?></option>
							<?php endforeach; endif; else: echo "" ;endif; ?>
						</select>
						<link rel="stylesheet" type="text/css" href="__ROOT__/static/admin/css/daterangepicker.css" />
						<script type="text/javascript" src="__ROOT__/static/public/js/moment.js"></script>
						<script type="text/javascript" src="__ROOT__/static/public/js/daterangepicker.js"></script>
						<style>
							.daterangepicker{
								display:none;
								border: 1px solid #08C;
							}
						</style>
						<button type="button" class="button button-default pull-right" id="daterange-btn">
							<span>
							<?php if($_GET['start_time']): ?>
							<?php echo $_GET['start_time']; ?> 至 <?php echo $_GET['end_time']; else: ?>
							  <i class="icon-calendar"></i> 日期选择
							<?php endif; ?>
							</span>
							<i class="icon-caret-down"></i>
						</button>
						<script>
							var start_time="<?php echo input('get.start_time'); ?>",end_time="<?php echo input('get.end_time'); ?>";
							$('#daterange-btn').daterangepicker({
									ranges: {
										'今天': [moment(), moment()],
										'本周': [moment().startOf('week'), moment().endOf('week')],
										'本月': [moment().startOf('month'), moment().endOf('month')],
										'今年': [moment().startOf('year'), moment().endOf('year')]
									},
									startDate: moment(),
									endDate: moment().endOf('month')
								},
								function(start, end) {
									start_time = start.format('YYYY-M-DD');
									end_time = end.format('YYYY-M-DD');
									$('#daterange-btn span').html(start_time + ' 至 ' + end_time);
								}
							);
						</script>
						<a type="button" class="button button border-yellow search_t" href="#" />
						<?php echo lang('label')['search']; ?></a>
						 <a type="button" class="button button border-yellow search" href="#" /><?php echo lang('label')['order_id']; ?>
						<?php echo lang('label')['search']; ?></a>
						<a href="?">取消搜索</a>
						<a class="button button border-blue" style="float: right;margin-right: 20px" href="javascript:dispatch('&aid=<?php echo input('get.aid'); ?>')">订单调度系统</a>
					</div>
					<table class="table table-hover">
						<tr>
							<th width="120"><?php echo lang('label')['order_id']; ?></th>
							<th width="120"><?php echo lang('label')['type']; ?></th>
							<th width="120"><?php echo lang('label')['seller']; ?></th>
							<th width="120"><?php echo lang('label')['phone']; ?></th>
							<th width="100">满减</th>
							<th width="30">首减</th>
							<th width="30"><?php echo lang('label')['price']; ?></th>
							<th width="50"><?php echo lang('label')['name']; ?></th>
							<th width="100"><?php echo lang('label')['phone']; ?></th>
							<th width="100"><?php echo lang('label')['address']; ?></th>
							<th width="50"><?php echo lang('label')['status']; ?></th>
							<th width="50"><?php echo lang('label')['express']; ?></th>
							<th width="100">下单<?php echo lang('label')['time']; ?></th>
							<th width="100"><?php echo lang('label')['finish']; ?><?php echo lang('label')['time']; ?></th>
							<th width="100"><?php echo lang('label')['handle']; ?></th>
						</tr>
						<?php if(is_array($data) || $data instanceof \think\Collection || $data instanceof \think\Paginator): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$order): $mod = ($i % 2 );++$i;?>
						<tr>
							<td><?php echo $order['order_id']; ?></td>
							<td style="line-height:40px"><?php if($order['type'] == 0): ?>外卖<?php else: ?>到店<?php endif; ?></td>
							<td style="line-height:40px"><?php if($order['advance'] != 0): ?><font style="color: red;">【预定】</font><?php endif; ?><?php echo $order['title']; ?></td>
							<td style="line-height:40px"><?php echo $order['sellerphone']; ?></td>
							<td style="line-height:40px"><?php if($order['money_off_text']): ?><?php echo $order['money_off_text']; else: ?>无<?php endif; ?></td>
							<td style="line-height:40px"><?php if($order['new_user_reduction']): ?><?php echo $order['new_user_reduction']; else: ?>无<?php endif; ?></td>
							<td style="line-height:40px"><?php echo $order['last_price']; ?></td>
							<td style="line-height:40px"><?php echo $order['name']; ?></td>
							<td style="line-height:40px"><?php echo $order['phone']; ?></td>
							<td style="line-height:40px"><?php echo $order['address']; ?></td>
							<?php if($order['type'] == 0): ?>
							<td style="line-height:40px"><?php if($order['status'] == "1"): ?><span class="text-red"><?php echo lang('label')['order_status_1']; ?></span><?php elseif($order['status'] != 2 || $order['advance_receive'] != 0): ?><span class="text-sub"><?php echo lang('label')['order_status_'.$order['status']]; ?></span><?php else: ?>等待商家接单<?php endif; ?></td>
							<td style="line-height:40px"><?php echo $order['express_name']; ?></td>
							<?php else: ?>
							<td style="line-height:40px"><?php if($order['status'] == "1"): ?><span class="text-red"><?php echo lang('label')['order_status_1']; ?></span><?php elseif($order['status'] != 2 || $order['advance_receive'] != 0): ?><span class="text-sub"><?php echo lang('label')['order_status_'.$order['status']]; ?></span><?php else: ?>等待商家接单<?php endif; ?></td>
							<td style="line-height:40px"><?php echo $order['express_name']; ?></td>
							<?php endif; ?>
							<td style="line-height:40px"><?php echo date("Y-m-d H:i",$order['time']); ?></td>
							<td style="line-height:40px"><?php if($order['complete_time']): ?><?php echo date("Y-m-d H:i",$order['complete_time']); else: ?>未完成<?php endif; ?></td>
							<td style="line-height:40px">
								<a class="button border-blue button-little" href="javascript:show_detail('<?php echo $order['order_id']; ?>')"><?php echo lang('currency')['detail']; ?></a>
								<?php if($order['status'] >= 2 && $order['status'] <= 4): ?>
									<a class="button border-yellow button-little" href="__URL__/?cancel=ok&order_id=<?php echo $order['order_id']; ?>&page=<?php echo $pages['page']; ?>" onclick="if(!confirm('确认取消该订单？'))return false;">取消</a>
								<?php endif; ?>
							</td>
						</tr>
						<?php endforeach; endif; else: echo "" ;endif; ?>
					</table>
					<?php if($pages['pagetotal'] > 1): 
	$get_arr = request()->get();
	$parameters = '';
	if(count($get_arr) > 0){
		foreach($get_arr as $k => $v){
			if($k != 'page'){
				$parameters .= '&'.$k.'='.$v;
			}
		}
	}
	 ?>
	<div class="panel-foot text-center">
		<ul class="pagination green">
			<li><a href="#">共<?php echo $pages['total']; ?>条数据</a></li>
		</ul>
		<?php if($pages['page'] > 1): ?>
		<ul class="pagination">
			<li><a href="?page=<?php echo $pages['page']-1; ?><?php echo $parameters; ?>">上一页</a></li>
		</ul>
		<?php endif; ?>
		
		<ul class="pagination pagination-group">
		<?php $__FOR_START_15555__=1;$__FOR_END_15555__=$pages['pagetotal']+1;for($i=$__FOR_START_15555__;$i < $__FOR_END_15555__;$i+=1){ ?>
		<li><a href="?page=<?php echo $i; ?><?php echo $parameters; ?>" <?php if($pages['page']==$i): ?>class="active"<?php endif; ?>><?php echo $i; ?></a></li>
		<?php } ?>
		</ul>
		<?php if($pages['page'] < $pages['pagetotal']): ?>
		<ul class="pagination">
			<li><a href="?page=<?php echo $pages['page']+1; ?><?php echo $parameters; ?>">下一页</a></li>
		</ul>
		<?php endif; ?>
	</div>
<?php endif; ?>

				</div>
			</form>
			<script>
			layer.config({
				extend: 'extend/layer.ext.js'
			});
			var last_time = "<?php echo $last_time; ?>";
			function update_order() {
				$.post("__URL__/socket?type=order&aid=<?php echo input('get.aid'); ?>",{},function (newtime) {
					if(newtime > last_time){
						layer.msg('订单列表发生变化！');
						refrush();
					}
				})
			}

			function auto() {
				update_order();
				setTimeout(function () {
					auto();
				},30000);
			}
			auto();

			function refrush() {
				setTimeout(function () {
					window.location.reload();
				},700)
			}
			$('#select_del').click(function(){
				var str=""; 
				$("input:checkbox[name=id]:checked").each(function(){ 
					str+=$(this).val()+",";
				});
				if(str!=''){
					if(confirm("<?php echo lang('currency')['del']; ?>?")){location.href='order/del.html?id='+str;}
				}
			});
            function dispatch(order_id) {
                parent.layer.open({
                    type: 2,
                    title:'订单调度系统',
                    area: ['100%', '100%'], //宽高
                    maxmin: true,
                    shade : false,
                    content: '__URL__/dispatch?order_id='+order_id
                });
            }
			function  show_detail(order_id) {
                layer.open({
                    type: 2,
                    title:'订单详情',
                    //skin: 'layui-layer-rim', //加上边框
                    area: ['500px', '600px'], //宽高
                    content: '__URL__/detail.html?order_id='+order_id
                });
            }
			$('.search').click(function(){
				layer.prompt({title:'<?php echo lang('label')['order_id']; ?><?php echo lang('label')['search']; ?>'},function(val){
					location.href="__ROOT__/admin/order.html?order_id="+val;
				});
			});
			$('.search_t').click(function(){
				var express_id = $("#express").val();
				var seller_id = $("#seller").val();
				var status = $("#status").val();
				location.href="<?php echo url('/admin/order'); ?>?pid="+pid+"&cid="+cid+"&aid="+aid+"&status="+status+"&seller_id="+seller_id+"&express_id="+express_id+"&start_time="+start_time+"&end_time="+end_time;
			});
			</script>
<p class="text-center text-gray" style="margin-top:10px;"><a class="text-gray" target="_blank" href="http://www.wm0530.com">完美外卖系统 Power by 网络工厂</a></p>
</body>
<script>
$('.upload').on('click',function (){
		var id = $(this).attr('data-id');
		 upload(id);
	}
);
function upload(id){
	layer.open({
		type:2,
		title:false,
		area: ['70%', '90%'],
		offset: '5%',
		content: "<?php echo url('/admin/material'); ?>?id="+id
	});
}
</script>
</html>